﻿using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.WebAPI.Application.Command.SheepAblactationCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.SheepAblactationCommandHandler
{
    public class GetEweEarTagsFromSheepFileCommandHandler : IRequestHandler<GetEweEarTagsFromSheepFileCommand, Results<List<Eartag>>>
    {
        private readonly ISheepAblactationService _sheepAblactationService;

        public GetEweEarTagsFromSheepFileCommandHandler(ISheepAblactationService sheepAblactationService)
        {
            _sheepAblactationService = sheepAblactationService;
        }
        /// <summary>
        /// 处理GetEweEarTagsFromSheepFileCommand请求。
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<List<Eartag>>> Handle(GetEweEarTagsFromSheepFileCommand request, CancellationToken cancellationToken)
        {
            return Results<List<Eartag>>.DataResult(await _sheepAblactationService.GetEweEarTagsFromSheepFile());
        }
    }
}
